from fastapi import APIRouter

from app.crud.prediction import generate_24h_prediction
from app.schemas.prediction import PredictionRequest, PredictionOut
from app.utils.Result import Result

router = APIRouter()

@router.post(
    "/predict",
    response_model=Result[PredictionOut],
    summary="生成未来24小时预测数据",
    description="根据类型（如solar, wind, load）和参数ID，生成未来24小时预测数据"
)
async def generate_24h_prediction_api(request: PredictionRequest):
    try:
        result = await generate_24h_prediction(request.type, request.id)
        return Result.ok(result, msg="预测数据生成成功")
    except ValueError as e:
        return Result.error(code=400, msg=str(e))